package
{
	import com.interfaces.game.GlobalAPI;
	import com.interfaces.general.AbstractDisplayObject;
	
	import fl.controls.Button;
	import fl.controls.progressBarClasses.IndeterminateBar;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	import flash.utils.ByteArray;
	
	import map.Char;
	
	public class dsds extends AbstractDisplayObject {
		
		private var btn:Button = new Button;
		private var char:Char = new Char
			
		private var url:URLLoader
		public function dsds() {
			super();
			addEventListener(Event.ADDED_TO_STAGE,addToStageHandler);
			addChild(btn);
			btn.addEventListener(MouseEvent.CLICK,clickHandler);
			char.x = 100;
			char.y = 100;
			
			url = new URLLoader;
			url.dataFormat = URLLoaderDataFormat.BINARY;
			url.addEventListener(Event.COMPLETE,comHandler);
			url.load(new URLRequest("../res/4.bin"));
		}
		
		private function comHandler(e:Event):void{
//			trace(url.data);
//			var byteArray:ByteArray = url.data as ByteArray;
//			var str:String =""
//			var id:int = 8;
//			for(var i:int =0 ;i<byteArray.length;i++){
//				str+=byteArray.readUTF();
//				if(id <=0){
//					id = 8
////					str+=" ";
//				}
//				id --;
//			}
			
//			trace(byteArray.readUTF());
//			trace(str);
		}
		
		private function clickHandler(e:Event):void{
			if(this.contains(char)){
				this.removeChild(char);
			}else{
				this.addChild(char);
			}
		}
		private function addToStageHandler(e:Event):void{
			GlobalAPI.init(this.stage);
		}
		
	}
}